﻿#Include, <JSON>
FileRead, OutputVar, 41451字.txt
Loop, Parse, OutputVar, `n, `r
{
    t:=JSON.Load(SendRequest("http://www.xhup.club/Xhup/Search/searchCode","POST","search_word=" (A_LoopField),{"Content-Type":"application/x-www-form-urlencoded"})).list_dz.1.1
    If (t != ""){
        FileAppend, %t%`n, xhup.txt, UTF-8
        OutputDebug, % A_Index "|" t
    }
}
SendRequest(url, Method="GET", postData="", headers="", Encoding="")
{
	hObject:=ComObjCreate("WinHttp.WinHttpRequest.5.1")
	hObject.SetTimeouts(30000, 30000, 30000, 30000) 
	hObject.Open(Method, url, (Method="POST" ? 1 : 0))  
	
	if IsObject(headers){
		for k, v in headers
			if v
				hObject.SetRequestHeader(k, v)
	}
	if postData{
		try
			hObject.Send(postData)
		try
			hObject.WaitForResponse(-1)
	} else {
		try
			hObject.Send()
	}

	if (Encoding && hObject.ResponseBody)
	{
		oADO:=ComObjCreate("adodb.stream")
		oADO.Type:=1, oADO.Mode:=3
		oADO.Open(),oADO.Write(hObject.ResponseBody)
		oADO.Position:=0, oADO.Type:=2
		oADO.Charset:=Encoding
		return oADO.ReadText(), oADO.Close()
	}
	try 
		return hObject.ResponseText
}

Urlencode(string, encoding:="utf-8")
{
	bt:=StrPutVar(string,sb,encoding)
	Loop % bt
	{
		hex:=format("{1:02x}", hex2:=NumGet(&sb, A_index-1, "Uchar"))
		;msgbox % hex "|" hex2 "|" chr(hex2)
		if hex2
		if (hex2==33 || (hex2>=39 && hex2 <=42) || hex2==45 || hex2 ==46 || (hex2>=48 && hex2<=57) || (hex2>=65 && hex2<=90) || hex2==95 || (hex2>=97 && hex2<=122) || hex2==126)
			content .=Chr(hex2)
		else
			content .="`%" hex
	}
	return content
}
